import Vue from 'vue'
import Vuex from 'vuex'
import App from './App'
import router from './router'
import store from '@/vuex/store.js'   //vuex
import { userInfo } from '@/api/index'
import less from 'less'
import Mint from 'mint-ui';    //移动端UI
import 'mint-ui/lib/style.css'
Vue.use(Mint);
Vue.config.productionTip = false


// 用钩子函数beforeEach()对路由进行判断
// const whiteList = ['/home']
// router.beforeEach((to, from, next) => {
//   if (whiteList.indexOf(to.path) !== -1) {
//     next()
//   } else {
//     if (store.state.login === 1) {
//       next()
//     } else {
//       userInfo().then(res => {
//         if (res.code === 1) {
//           store.state.login.token = 1
//           next()
//         } else {
//           store.state.login.token = 0
//           console.log(2)
//           next({
//             path: '/login'
//           })
//         }
//       })
//     }
//   }
// })


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
